<template lang="pug">
.content
  .row
    .col-md-12
      md-card(title='客人列表', category='通过 MAC 地址识别客人数据', backgroundColor='purple')
        md-table(apiUrl="/macs/all" :columns='maclist.columns' :titles='maclist.titles')
</template>

<script>
export default {
  data() {
    function dateRender(item) {
      return new Date(item.date).toLocaleString()
    }
    function userRender(item) {
      let user = item.user
      if (!user || !user.name) {
        return ''
      }
      return `<a href="#/users/id/${user._id}">${user.name}</a>`
    }
    return {
      maclist: {
        columns: ['bssid', userRender, dateRender, 'rssi', 'channel'],
        titles: ['MAC 地址', '用户名', '感知时间', '信号强度', '信道']
      }
    }
  }
}
</script>
